as31 to the rescue ------------------ 1) You can easily double check your some of your work with the as31 assembler by typing in using a text editor (i.e. notepad or wordpad) a file hw4.asm: org 0x0 .byte 'a' ;unsigned char x='a'; .byte -'a' ;unsigned char x=-'a'; .byte 255o ;unsigned char x=0255; ;...fill in rest .word 256 ;unsigned short x=256; .end 2) Then run the assembler: as31 -l hw4.asm AS31 2.0b3 (beta), March 20, 2001 Please report problems to: paul@pjrc.com Begin Pass #1 Begin Pass #2 *** Don't send any emails to paul@pjrc.com *** That is a normal output message. *** If you get an error, you have mis-typed something. 3) Then read the listing file with a text editor: hw4.lst which will show you the hex output for two's complement. 0000: .org 0x0 0000: 61 start: .byte 'a' ;unsigned char x='a'; 0001: 9F .byte -'a' ;unsigned char x=-'a'; 0002: AD .byte 255o ;unsigned char x=0255; ;...fill in rest 0003: 01 00 .word 256 ;unsigned short x=256; 0005: .end Also, > Prof Wolff, > > Im doing the hw and I've got a few questions for you: Im looking at > problem 1 first row. You list the exercize as unsigned char x='a'. > Checking my ASCII charts shows that as a decimal 97 which becomes a > 01100001. Then, big endian twos complement should be 10011110, which > isn't what you list. What did I do wrong? If you look at page 40, table 2-6, all positive numbers are the same for one's, two's complement and sign magnitude. It's when you have negative or zero numbers that they differ. Sometimes, we say the "two's complement representation" or we take the "two's complement" of a negative number, meaning we first get the positive number and ignore the negative part; then we take the "complement" to get the negative representation of the number. For example: ------------ 01100001 is the two's complement "representation" of the positive number of 'a' 10011111 is two's complement "representation" of -'a', see page 37 and 10011110 is one's complement "representation of -'a', see pag 38 --Prof. Wolff.