The MASM Forum

General => The Campus => Topic started by: Evan on December 07, 2013, 04:09:51 PM

Title: What if I mess up?
Post by: Evan on December 07, 2013, 04:09:51 PM
Do not do this code it's is a MASM that kinda went wrong ...

byte1 BYTE '0111h'
Title: Re: What if I mess up?
Post by: dedndave on December 07, 2013, 05:38:32 PM
 :biggrin:

BYTE's contain 8 bits
111h is 9 bits - you need at least a WORD
Title: Re: What if I mess up?
Post by: Evan on December 09, 2013, 06:38:59 PM
A word is bigger than a byte.
Title: Re: What if I mess up?
Post by: dedndave on December 09, 2013, 06:47:33 PM
BYTE, 8 bits
WORD, 16 bits
DWORD, 32 bits  (same size as REAL4)
QWORD, 64 bits  (same size as REAL8)
OWORD, 128 bits

TBYTE, 80 bits  (same size as REAL10)
Title: Re: What if I mess up?
Post by: Evan on December 09, 2013, 06:50:32 PM
Would
byte1 BYTE '0100h'
work?
Title: Re: What if I mess up?
Post by: dedndave on December 09, 2013, 06:51:26 PM
9 bits
0001 0000 0000

for 8 bits, the max is 0FFh
1111 1111
Title: Re: What if I mess up?
Post by: dedndave on December 09, 2013, 06:54:16 PM
you could use 2 bytes
    db 0,1
very similar to
    dw 100h
Title: Re: What if I mess up?
Post by: Evan on December 09, 2013, 07:01:18 PM
Quote from: Evan on December 09, 2013, 06:50:32 PM
Would
byte1 BYTE '0100h'
work?
Is it this?
byte1 BYTE '0FFh'


or


byte1 BYTE 'FFh'

What does a full byte in hex look like?

Is 0xFF a full byte?
Title: Re: What if I mess up?
Post by: Evan on December 09, 2013, 07:27:25 PM
Quote from: dedndave on December 09, 2013, 06:51:26 PM
9 bits
0001 0000 0000

for 8 bits, the max is 0FFh
1111 1111



Quote from: dedndave on December 07, 2013, 05:38:32 PM
:biggrin:


BYTE's contain 8 bits
111h is 9 bits - you need at least a WORD
Yes. If 8 bits is a byte.

:D


So 0xFF is like 99(base ten)


and my calculator says 256 or 255 base ten must be a full byte.
Title: Re: What if I mess up?
Post by: dedndave on December 09, 2013, 07:34:34 PM
a byte holds 8 bits, in common parlance

in binary
11111111
or
1111  1111

in hexadecimal
FF
or
0FFh

in decimal
255

the range for a signed byte is -128 to +127
the range for an unsigned byte is 0 to 255
Title: Re: What if I mess up?
Post by: Evan on December 09, 2013, 07:37:38 PM
Quote from: dedndave on December 09, 2013, 07:34:34 PM
a byte holds 8 bits, in common parlance

in binary
11111111
or
1111  1111

in hexadecimal
FF
or
0FFh

in decimal
255

the range for a signed byte is -128 to +127
the range for an unsigned byte is 0 to 255
How do I figure out the explanation of making negative numbers on the computer?


Is that how signing works somehow?
Title: Re: What if I mess up?
Post by: Evan on December 09, 2013, 08:14:28 PM
Is this it?
http://en.wikipedia.org/wiki/Signedness (http://en.wikipedia.org/wiki/Signedness)


Is this MASM friendly?
[quote source='wikipedia']For example, 0xFFFFFFFF gives −1, but 0xFFFFFFFFU gives 4,294,967,295 for 32-bit code.[/quote]


Would 0xFF be -1(base ten) and 0xFFU be 256(base ten) or 255(base ten)?


I would like to believe 0xFFU is 256(base ten) with all numbers being natural numbers including zero.
Title: Re: What if I mess up?
Post by: sinsi on December 09, 2013, 09:19:21 PM
Evan, you and dave seem to be talking about two different things.
This code works because it is a string due to using quotes
byte1 BYTE '0111h'
Without the quotes it is a number which is too big for a byte
byte1 BYTE 0111h
Title: Re: What if I mess up?
Post by: dedndave on December 10, 2013, 03:20:28 AM
hi sinsi - i saw the quotes - my assumption was that was how he got it to assemble without error
but, the intent was to define a value as hexadecimal - not a string

Evan - you may want to do some reading on basic data concepts
signed values normally use "two's compliment" form
you can google that term and find many descriptive texts

https://courses.engr.illinois.edu/ece390/books/artofasm/artofasm.html (https://courses.engr.illinois.edu/ece390/books/artofasm/artofasm.html)

start with chapter 1 - then, ask questions when something isn't clear   :t

you can put that url into translate.google.com (http://translate.google.com) and it will translate the entire site for you
by the way - what is your native language ???
Title: Re: What if I mess up?
Post by: Evan on December 10, 2013, 07:15:32 AM
Quote
Quote from: dedndave on December 10, 2013, 03:20:28 AM
hi sinsi - i saw the quotes - my assumption was that was how he got it to assemble without error
but, the intent was to define a value as hexadecimal - not a string

Evan - you may want to do some reading on basic data concepts
signed values normally use "two's compliment" form
you can google that term and find many descriptive texts

https://courses.engr.illinois.edu/ece390/books/artofasm/artofasm.html (https://courses.engr.illinois.edu/ece390/books/artofasm/artofasm.html)

start with chapter 1 - then, ask questions when something isn't clear   :t

you can put that url into translate.google.com (http://translate.google.com) and it will translate the entire site for you
by the way - what is your native language ???
Yeah well don't we always need a 0 in computers?
Does 0xFFU meaning 256(baseten) make sense?
Where I know that register is a positive one?
Including zero?


Or can I not use zero in this register and did my machine break?


Would my machine be okay if I don't use 0 in the register?


Do I then get to count up 1 to 256


Or can I count 0 to 256 in 0xFFU this whole time?
0 to 255
1 to 256
0 to 256


In 0xFFU
I am not sure.


Should I go with 0xFF meaning 255(baseten) and 0xFFU meaning ((-255 to 255))(base ten)?
Title: Re: What if I mess up?
Post by: Gunther on December 10, 2013, 07:24:10 AM
Evan,

Quote from: Evan on December 10, 2013, 07:15:32 AM
Yeah well don't we always need a 0 in computers?

in most cases. Otherwise we would give away one digit.

Quote from: Evan on December 10, 2013, 07:15:32 AM
Does 0xFFU meaning 256(baseten) make sense?

0xffh = 255 decimal.

Gunther
Title: Re: What if I mess up?
Post by: Evan on December 10, 2013, 07:57:14 AM
Quote from: Gunther on December 10, 2013, 07:24:10 AM
Evan,

Quote from: Evan on December 10, 2013, 07:15:32 AM
Yeah well don't we always need a 0 in computers?

in most cases. Otherwise we would give away one digit.

Quote from: Evan on December 10, 2013, 07:15:32 AM
Does 0xFFU meaning 256(baseten) make sense?

0xffh = 255 decimal.

Gunther
Gunther I hope it is recognized we tried to declare hexadecimal notation twice in the assembler.
With 0x
and h






Or could you please explain the one way to declare an hexadecimal number in the assembler?


Or where do we use one or the other?
Title: Re: What if I mess up?
Post by: dedndave on December 10, 2013, 09:31:55 AM
the 0xFF notation is used in C and other languages
normal MASM syntax is 0FFh
the leading 0 is only required if the first hex digit is a letter
so, 96h is also acceptable form

hexadecimal format values are not generally used for signed values
we would use decimal format
bNeg db -128
bPos db 127
Title: Re: What if I mess up?
Post by: Evan on December 10, 2013, 09:38:54 AM
I just ran this
MOV EAX, cons1mille
with many code exits.

Defining the cons1mille using this
INCLUDE CONS.INC

By making a CONS.INC file.
Title: Re: What if I mess up?
Post by: dedndave on December 10, 2013, 09:40:49 AM
i don't know what you defined it as, but ok
Title: Re: What if I mess up?
Post by: Evan on December 10, 2013, 09:41:58 AM
Quote from: dedndave on December 10, 2013, 09:31:55 AM
the 0xFF notation is used in C and other languages
normal MASM syntax is 0FFh
the leading 0 is only required if the first hex digit is a letter
so, 96h is also acceptable form

hexadecimal format values are not generally used for signed values
we would use decimal format
bNeg db -128
bPos db 127


Would

96(base hex) = FF(base hex)
Annihilate the hex number system then?
-----------------------------------------------------------


0FFh
vs
0x01
vs
01h
vs
1h


My question is 0FFh going to be the way of the byte?

Basically there are many variations of a full byte.

I'll try to figure out more about hex and bytes later.

I take it
0FFh
0FEh
0FDh
0FCh
0FBh
0FAh
0F9h
0F8h
0F7h
0F6h
0F5h
0F4h
0F3h
0F2h
0F1h
0F0h
; lol
0E0h

0E1h
0E2h
0E3h
0E4h
0E5h
0E6h
0E7h
0E8h
0E9h
0EAh
0EBh
0ECh
0EDh
0EEh
0EFh
will work too for a byte.
Title: Re: What if I mess up?
Post by: Evan on December 10, 2013, 09:44:26 AM
Quote from: dedndave on December 10, 2013, 09:40:49 AM
i don't know what you defined it as, but ok
I defined it like this cons1mille  EQU 1000
.
Title: Re: What if I mess up?
Post by: dedndave on December 10, 2013, 10:49:08 AM
here's a good exercise....

write a little program that display all the hex values from 0 to FF, seperated by a space
so - you want to make 256 passes through a single loop
or - 16 passes on an outer loop and 16 passes on an inner loop
Title: Re: What if I mess up?
Post by: Evan on December 11, 2013, 07:57:36 PM
Quote from: dedndave on December 10, 2013, 10:49:08 AM
here's a good exercise....

write a little program that display all the hex values from 0 to FF, seperated by a space
so - you want to make 256 passes through a single loop
or - 16 passes on an outer loop and 16 passes on an inner loop

That sounds like a really fun time. I will try.